package com.c.ctgproject.adapter.service

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import android.widget.TextView
import com.c.ctgproject.R
import com.c.ctgproject.entity.AllSellerChildEntity

/**
 *作者:LiBW
 *创建日期: 2020/9/14
 *描述: 所有销售人员下拉框
 */
class CommonSpannerAdapter(val context: Context, val mList: List<String>) : BaseAdapter() {

    override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
        val view: View?
        val holder: MyViewHolder?
        if (convertView == null) {
            view = LayoutInflater.from(context).inflate(R.layout.item_spinner_layout, parent, false)
            holder = MyViewHolder(view)
            view.tag = holder
        } else {
            view = convertView
            holder = view.tag as MyViewHolder
        }
        holder.text.text = mList[position]
        return view!!
    }

    override fun getItem(position: Int): Any {
        return mList[position]
    }

    override fun getItemId(position: Int): Long {
        return position.toLong()
    }

    override fun getCount(): Int {
        return mList.size
    }

    inner class MyViewHolder(view: View) {
        val text: TextView = view.findViewById(R.id.mItemNameTV)
    }
}